<template>
  <div style="background-image: url('../../../static/img/sm3.jpeg');background-attachment:fixed;">
    <el-container>
      <el-main>
        <div class="hm">
          <el-breadcrumb separator-class="el-icon-arrow-right">
            <el-breadcrumb-item :to="{ path: '/index' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item>商品信息管理</el-breadcrumb-item>
          </el-breadcrumb>

        </div>
        <productList ref="productList" :tableData="tableData"></productList>
        <!--分页-->
        <el-pagination @current-change="paginationCurrentChange" :current-page.sync="currentPage" :page-size="pageSize"
                       layout="total, prev, pager, next, jumper" :total="dataLength" align="center">
        </el-pagination>

      </el-main>
    </el-container>
  </div>
</template>

<script>
import axios from 'axios'
import productList from "../../components/list/productList"

export default {

  name :"productInfo",
  data() {

    return {
      dialoguploadVisible:false,
      input: '',
      dataLength: 0,
      currentPage:1,
      pageSize:5,
      tableData:[],
    }
  },
  methods: {
    //换页
    paginationCurrentChange(val){
      this.currentPage=val
      this.$refs.productList.currentPage=this.currentPage
        this.tableData=this.selectAll(this)
    },
    selectAll(that){
      // that.$axios.get("http://39.96.93.100:6677/product/findAll","").then(
      that.$axios.post(that.$URL.queryproduct+'?page='+(that.currentPage-1)+'&pageSize='+that.pageSize).then(
          res=>{
            console.log(res.data.list)
            that.tableData=res.data.list
            that.dataLength=res.data.total
            console.log(res.status)
            if(res.status==200){
              that.dataLength = res.body.totalCount
              that.tableData=res.data.list
              console.log(that.tableData)
            }

          }
      ).catch(err=>{})
    },

    handleClick(){
      this.$Bus.$emit('addproduct',{
        dialogVisible:true
      })
    }
  },
  components: {
    productList
  },
  mounted () {
    this.tableData=this.selectAll(this)
  },
}
</script>

<style lang="less" scoped>
.el-container {
  border: 1px solid #ddd;
  border-radius: 10px;
  margin: 10px;
  padding: 10px;
  min-height: 500px;
  .el-aside {
    color: #fff;

    .el-input {
      margin-bottom: 15px;
      width: 250px;
    }

    .el-menu {
      border-top: 1px solid #ddd;
      border-radius: 5px;
      width: 250px;
      min-height: 500px;
    }
  }

  .el-main {
    .hm {
      margin-bottom: 10px;
      margin-left: 30px;
    }
  }
}
</style>